package com.group18.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class DoUpdateAccount
 */
@WebServlet("/ToUpdateAccount")
public class ToUpdateAccount extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ToUpdateAccount() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("utf-8");
		
		int id = Integer.parseInt(request.getParameter("id"));
		String username = request.getParameter("username");
		String state = request.getParameter("state");
		String label = request.getParameter("label");
		String statue = request.getParameter("statue");
		double money = Double.parseDouble(request.getParameter("money"));
		String date = request.getParameter("date");
		int family_id = Integer.parseInt(request.getParameter("family_id"));
		int member_id = Integer.parseInt(request.getParameter("member_id"));
		
		request.setAttribute("id", id);
		request.setAttribute("username", username);
		request.setAttribute("state", state);
		request.setAttribute("label", label);
		request.setAttribute("statue", statue);
		request.setAttribute("money", money);
		request.setAttribute("date", date);
		request.setAttribute("family_id", family_id);
		request.setAttribute("member_id", member_id);
		request.getRequestDispatcher("/WEB-INF/jsp/updateAccount.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
